From: Ryan Harper Date: Thu, 11 May 2006 12:49:20 +0000 (+0100) Subject: Fix up enforce_dom0_cpu test case to check that dom0 has at least 2 vcpus X-Git-Tag: archive/raspbian/4.8.0-1+rpi1~1^2~16047^2~85 X-Git-Url: https://dgit.raspbian.org/%22http://www.example.com/cgi/success//%22http:/www.example.com/cgi/success/?a=commitdiff_plain;h=6cd2d711bee124a2305c7e75d642ed9f270bfdc5;p=xen.git Fix up enforce_dom0_cpu test case to check that dom0 has at least 2 vcpus online. Also fix bogus call to vcpu-enable; xm now uses vcpu-set as method for enable/disable of vcpus. Previously after a successful test run, this test would not leave dom0 in the same state as it was when the test started. Also some comment language changes and 80 column formatting. --- diff --git a/tools/xm-test/tests/enforce_dom0_cpus/01_enforce_dom0_cpus_basic_pos.py b/tools/xm-test/tests/enforce_dom0_cpus/01_enforce_dom0_cpus_basic_pos.py index 576796623f..9de44d6aa7 100644 --- a/tools/xm-test/tests/enforce_dom0_cpus/01_enforce_dom0_cpus_basic_pos.py +++ b/tools/xm-test/tests/enforce_dom0_cpus/01_enforce_dom0_cpus_basic_pos.py @@ -4,20 +4,23 @@ # Authors: Dan Smith # Ryan Harper -# 1) Make sure we have a multi cpu system +# 1) Make sure we have a multi cpu system and dom0 has at +# least 2 vcpus online. # 2) clone standard config (/etc/xen/xend-config.sxp) # 3) modify clone with enforce_dom0_cpus=X # 4) restart xend with modified config # 5) check /proc/cpuinfo for cpu count -# 6) check xm list -v to see that only 1 cpu is online for dom0 -# 7) Restart xend with default config +# 6) check xm info 'VCPUs' field to see that only 'enforce_dom0_cpus' +# number of cpus are online in dom0 +# 7) Restore initial dom0 vcpu state +# 8) Restart xend with default config import sys import re import time import os -# what value should dom0_cpus be enforced? +# what value should dom0_cpus enforce? enforce_dom0_cpus=1 from XmTestLib import * @@ -25,12 +28,19 @@ from XmTestLib import * check_status = 1 max_tries = 10 -# 1) Make sure we have a multi cpu system +# 1) Make sure we have a multi cpu system and dom0 has at least 2 vcpus online. if smpConcurrencyLevel() <= 1: print "*** NOTE: This machine does not have more than one physical" print " or logical cpu. The vcpu-disable test cannot be run!" SKIP("Host not capable of running test") + +# count number of online vcpus in dom0 +dom0_online_vcpus = int(getDomInfo("Domain-0", "VCPUs")) +if dom0_online_vcpus <= 1: + print "*** NOTE: DOM0 needs at least 2 VCPUs online to run this test" + print " Please enable additional vcpus if possible via xm vcpu-set" + SKIP("Host state not capable of running test") # 2) clone standard config (/etc/xen/xend-config.sxp) # 3) modify clone with enforce_dom0_cpus=1 @@ -65,26 +75,33 @@ if check_status and status != 0: if output != str(enforce_dom0_cpus): os.unsetenv("XEND_CONFIG") restartXend() - FAIL("/proc/cpuinfo says xend didn't enforce dom0_cpus (%s != %s)" %(output, enforce_dom0_cpus)) + FAIL("/proc/cpuinfo says xend didn't enforce dom0_cpus (%s != %s)"%(output, + enforce_dom0_cpus)) -# 7) count number of online cpus and see that it matches enforce value -dom0vcpus = getVcpuInfo("Domain-0") -num_online = len(filter(lambda x: x >= 0, dom0vcpus.values())) +# 6) count number of online cpus and see that it matches enforce value +num_online = int(getDomInfo("Domain-0", "VCPUs")) if num_online != enforce_dom0_cpus: os.unsetenv("XEND_CONFIG") restartXend() - FAIL("xm says xend didn't enforce dom0_cpus (%s != %s)" %(num_online, enforce_dom0_cpus)) - -# restore dead processors -for (k,v) in zip(dom0vcpus.keys(),dom0vcpus.values()): - if v == -1: - status, output = traceCommand("xm vcpu-enable 0 %s"%(k)) - if check_status and status != 0: - os.unsetenv("XEND_CONFIG") - restartXend() - FAIL("\"%s\" returned invalid %i != 0" %(cmd,status)) - -# Restart xend with default config + FAIL("xm says xend didn't enforce dom0_cpus (%s != %s)" %(num_online, + enforce_dom0_cpus)) + +# 7) restore dead processors +status, output = traceCommand("xm vcpu-set 0 %s"%(dom0_online_vcpus)) +if check_status and status != 0: + os.unsetenv("XEND_CONFIG") + restartXend() + FAIL("\"%s\" returned invalid %i != 0" %(cmd,status)) + +# check restore worked +num_online = int(getDomInfo("Domain-0", "VCPUs")) +if num_online != dom0_online_vcpus: + os.unsetenv("XEND_CONFIG") + restartXend() + FAIL("failed to restore dom0's VCPUs") + + +# 8) Restart xend with default config os.unsetenv("XEND_CONFIG") restartXend()